<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/templates/templateListar.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">

	<ui:define name="conteudo">
		<ui:param name="actionBean" value="#{racaMB}" />

		<h:form id="frmRaca">

			<p:hotkey bind="esc"
				handler="document.getElementById('frmTab:btnCancelar').click()" />


		</h:form>

		<h:form id="frmTab">
			<p:commandButton id="btnCancelar" action="#{racaMB.sair}"
				immediate="true" style="display:none" value="cancelar" />
			<p:commandButton actionListener="#{racaMB.abrirModal}" ajax="true"
				style="float:left" icon="ui-icon-disk" title="Incluir"
				update=":dialogCadastro" value="Novo Registro"
				oncomplete="dialogCadastroRaca.show()">
				<f:param name="modooperacao" value="INCLUIR" />
			</p:commandButton>
			<p:dataTable id="tabela" var="item" value="#{racaMB.lista}"
				paginator="true" rows="10" emptyMessage="Não há registros"
				paginatorPosition="bottom"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				currentPageReportTemplate="(Página: {currentPage}/{totalPages})"
				rowsPerPageTemplate="10,15,25,50,100" selectionMode="single"
				rowKey="#{item.codigo}">
				<f:facet name="header">Cadastro de Raças
					
				</f:facet>
				<p:column headerText="Código" sortBy="#{item.codigo}">
					<h:outputText value="#{item.codigo}" />
				</p:column>
				<p:column headerText="Descricão" sortBy="#{item.nome}">

					<h:outputText value="#{item.descricao}" />

				</p:column>
				<p:column headerText="Porte" sortBy="#{item.porte.descricao}">

					<h:outputText value="#{item.porte.descricao}" />

				</p:column>


				<p:column headerText="Ações" style="text-align:center">

					<p:commandButton title="Alterar" icon="ui-icon-pencil"
						styleClass="styleBotao" actionListener="#{racaMB.abrirModal}"
						update=":dialogCadastro" ajax="true"
						oncomplete="dialogCadastroRaca.show()">

						<f:setPropertyActionListener value="#{item.clone()}"
							target="#{racaMB.racaSelecionada}" />
						<f:param name="modooperacao" value="ALTERAR" />
					</p:commandButton>

					<p:commandButton actionListener="#{racaMB.abrirModal}"
						styleClass="styleBotao" icon="ui-icon-search" title="Consultar"
						update=":dialogCadastro" ajax="true"
						oncomplete="dialogCadastroRaca.show()">
						<f:setPropertyActionListener value="#{item.clone()}"
							target="#{racaMB.racaSelecionada}" />
						<f:param name="modooperacao" value="CONSULTAR" />
					</p:commandButton>

					<p:commandButton title="Excluir" update=":Excluir"
						styleClass="styleRed" icon="ui-icon-close"
						oncomplete="confirmation.show()">

						<f:setPropertyActionListener target="#{racaMB.racaSelecionada}"
							value="#{item.clone()}" />
					</p:commandButton>

				</p:column>

				<f:facet name="footer">
					<p:outputLabel value="Total de " />
					<p:outputLabel value="#{fn:length(racaMB.lista)} registro(s)" />

				</f:facet>

			</p:dataTable>


		</h:form>

		<ui:include src="dialogCadastroRaca.xhtml" />
		<ui:include src="/includes/confirmacaoExcluir.xhtml" />
	</ui:define>
</ui:composition>

